<?php
declare(strict_types=1);

namespace App\Common\Query;

use Hyperf\Database\Model\Builder;

trait SearchIp
{
    /**
     * IP搜索器
     * @param Builder $query
     * @param $keyword
     * @return void
     */
    public function searchIp(Builder $query, $keyword): void
    {
        if (is_string($keyword) && strlen($keyword) > 0) {
            $query->where(['ip' => inet_pton($keyword)]);
        }
    }
}